package com.idbk.chargestation.api;

import com.android.volley.toolbox.StringRequest;
import com.idbk.chargestation.net.EHttpResponse;

import java.util.HashMap;
import java.util.Map;

/**
 * 充电点相关的API
 *
 * @author lupc, zhx
 */
public class APIForPoint {

    /**
     * 查询 充电点评论
     *
     * @param pointId   充电点Id
     * @param pageIndex 当前页数,从1开始，必须小于等于总页数
     * @param pageSize  每页评论数量
     * @param response  回调
     */
    public static StringRequest getPointComments(
            int pointId,
            int pageIndex,
            int pageSize,
            EHttpResponse response
    ) {
        final String URL = ChargeStationURL.format("/station/comment!get.do");
        Map<String, String> params = new HashMap<String, String>();
        params.put("model.pointId", pointId + "");
        params.put("model.pageIndex", pageIndex + "");
        params.put("model.pageSize", pageSize + "");
//        params.put("model.agentId", BuildConfig.VENDOR + "");
        return ChargeStationAPI.postWithToken(URL, params, response);
    }

    /**
     * 查询 充电点评论的回复
     *
     * @param pointCommentId 回复的评论ID
     * @param pageIndex      当前页数，从1开始，必须小于等于总页数
     * @param pageSize       每页评论数量
     * @param response       回调
     */
    public static StringRequest getPointCommentReplys(
            int pointCommentId,
            int pageIndex,
            int pageSize,
            EHttpResponse response
    ) {
        final String URL = ChargeStationURL.format("/station/comment!getReplys.do");
        Map<String, String> params = new HashMap<String, String>();
        params.put("model.chargePointCommentId", pointCommentId + "");
        params.put("model.pageIndex", pageIndex + "");
        params.put("model.pageSize", pageSize + "");
//        params.put("model.agentId", BuildConfig.VENDOR + "");
        return ChargeStationAPI.postWithToken(URL, params, response);
    }

    /**
     * 删除回复
     *
     * @param replyId  要删除的回复ID
     * @param response 回调
     */
    public static StringRequest deleteReply(
            int replyId,
            EHttpResponse response) {
        final String URL = ChargeStationURL.format("/station/comment!deleteReply.do");
        Map<String, String> params = new HashMap<String, String>();
        params.put("model.replyId", replyId + "");
        return ChargeStationAPI.postWithToken(URL, params, response);
    }

    /**
     * 删除评论
     *
     * @param commentId 要删除的评论ID
     * @param response  回调
     */
    public static StringRequest deleteComment(
            int commentId,
            EHttpResponse response) {
        final String URL = ChargeStationURL.format("/station/comment!delete.do");
        Map<String, String> params = new HashMap<String, String>();
        params.put("model.chargePointCommentId", commentId + "");
        return ChargeStationAPI.postWithToken(URL, params, response);
    }

    /**
     * 充电点 评论 点赞
     *
     * @param pointCommentId 要评论点赞的评论ID
     * @param response       回调
     */
    public static StringRequest doPointCommentPraise(
            int pointCommentId,
            EHttpResponse response
    ) {
        final String URL = ChargeStationURL.format("/user/praise!comment.do");
        Map<String, String> params = new HashMap<String, String>();
        params.put("model.chargePointCommentId", pointCommentId + "");
        return ChargeStationAPI.postWithToken(URL, params, response);
    }

    /**
     * 取消充电点 评论 点赞
     *
     * @param pointCommentId 要取消评论点赞的评论ID
     * @param response       回调
     */
    public static StringRequest undoPointCommentPraise(
            int pointCommentId,
            EHttpResponse response
    ) {
        final String URL = ChargeStationURL.format("/user/praise!undoComment.do");
        Map<String, String> params = new HashMap<String, String>();
        params.put("model.chargePointCommentId", pointCommentId + "");
        return ChargeStationAPI.postWithToken(URL, params, response);
    }

}
